import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import App from './app.vue'
import router from './lib/router'

import HaiguiExUI from 'galileo-ex-ui'

import sysInit from './common/sys-init.js'
import SubmitButton from './component/ex-submit-button.vue'

import md5 from 'js-md5';

Vue.prototype.$md5 = md5;


Vue.use(ElementUI, {size: 'small'})
Vue.component('submit-button', SubmitButton)

// 加载自定义控件
HaiguiExUI.install(Vue)
// 为上传控件设置上传、下载 url
Vue.prototype.$ex_default_upload_url = '/asama/aliyun/ResourceRpc/upload.json'
Vue.prototype.$ex_default_download_url = '/asama/aliyun/ResourceRpc/down.json?objectName='

// 登陆 url ，默认为 '/login.htm'
Vue.prototype.$ex_default_login_url = '/login'

Vue.prototype.$gridpanels = {}

sysInit(Vue)

new Vue({
  router,
  render: h => h(App),
  beforeCreate() {

    if(__LOGIN_USER__){
      Vue.prototype.$loginUser = __LOGIN_USER__
    }
    else{
      Vue.prototype.$loginUser = {}
    }

    Array.prototype.contains = function (obj) {
      var i = this.length;
      while (i--) {
        if (this[i] === obj) {
          return true;
        }
      }
      return false;
    }

    if (navigator.userAgent && (navigator.userAgent.indexOf('Windows') != -1 || navigator.userAgent.indexOf('Linux') != -1)) {
      var style = document.createElement("style");

      style.type = "text/css";

      try {
        style.appendChild(document.createTextNode("::-webkit-scrollbar { width: 8px;height: 1px; }"));
        style.appendChild(document.createTextNode("::-webkit-scrollbar-thumb { border-radius: 8px; -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2); background: #d6d6d6;}"));
        //style.appendChild(document.createTextNode("::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2); border-radius: 8px; background: #EDEDED; }"));
      } catch (ex) {
        style.styleSheet.cssText = "::-webkit-scrollbar { width: 8px;height: 1px; }  ::-webkit-scrollbar-thumb { border-radius: 8px; -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2); background: #d6d6d6;}  "; //针对IE
      }
      var head = document.getElementsByTagName("head")[0];
      head.appendChild(style);
    }


  }
}).$mount('#app')



